<?php
class ProductModel extends Model
{

    const BASE_PRODUCT = 0;
    const ADDITIONAL_PRODUCT = 1;

    public $rules = array(
        'name' => array('required'),
        'description' => array('required'),
        'image' => array('required'),
        'price' => array('required'),
        'available' => array('required'),
        'type' => array('required'),
    );
    public $attributes = array();
    public $tableName = 'product';

    public function getBaseProducts()
    {
        return $this->getAll("SELECT * FROM {$this->tableName} WHERE type=:type", array(':type' => self::BASE_PRODUCT));
    }

    public function getAdditionalProducts()
    {
        return $this->getAll("SELECT * FROM {$this->tableName} WHERE type=:type", array(':type' => self::ADDITIONAL_PRODUCT));
    }
}